home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 5
/
Aminet 5 - March 1995.iso
/
Aminet
/
gfx
/
show
/
jpegAGAsrc21.lha
/
jpegAGAsrc
/
jpegAGA
/
ASLfiles.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-01-14
|
3KB
|
113 lines
/* Display an ASL file requester */
#include <libraries/asl.h>
#include <workbench/startup.h>
#ifndef __GNUC__
#include <pragmas/exec_pragmas.h>
#include <pragmas/asl_pragmas.h>
#include <clib/exec_protos.h>
#include <clib/asl_protos.h>
#else
#include <inline/exec.h>
#include <inline/asl.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#define MAXFILES 500
extern char *PicArray[];
extern int NumPictures;
extern void CloseDisplay(void);
struct TagItem frtags[] =
{
{ ASLFR_InitialPattern,"#?.(jpg|jpeg)" },
{ ASLFR_DoMultiSelect, (ULONG)TRUE },
{ ASLFR_DoPatterns, (ULONG)TRUE },
{ ASLFR_RejectIcons, (ULONG)TRUE },
{ TAG_DONE, (ULONG)TRUE }
};
extern struct Library *AslBase;
void ChooseFiles(void)
{
struct FileRequester *fr;
struct WBArg *frargs;
int x,i;
if( AslBase=OpenLibrary("asl.library", 39L) )
{
if( fr = (struct FileRequester *)
AllocAslRequest(ASL_FileRequest, frtags) )
{
if( AslRequest(fr, NULL) )
{
/* multiselect */
if(fr->rf_NumArgs)
{
frargs=fr->rf_ArgList;
for(x=0; x < fr->rf_NumArgs; x++)
{
PicArray[NumPictures] = malloc(strlen(fr->rf_Dir)+strlen(frargs[x].wa_Name)+3);
if(!PicArray[NumPictures])
{
printf("Out of memory!\n");
FreeAslRequest(fr);
CloseLibrary(AslBase);
AslBase = NULL;
CloseDisplay();
exit(10);
}
strcpy(PicArray[NumPictures], fr->rf_Dir);
i = strlen(fr->rf_Dir);
if(i)
{
i--;
if(fr->rf_Dir[i] != ':' && fr->rf_Dir[i] != '/')
strcat(PicArray[NumPictures], "/");
}
strcat(PicArray[NumPictures], frargs[x].wa_Name);
/* puts(PicArray[NumPictures]); */
NumPictures++;
if(NumPictures == MAXFILES)
{
printf("Too many files!\n");
break;
}
}
}
else
{
/* only one file selected */
PicArray[NumPictures] = malloc(strlen(fr->rf_Dir)+strlen(fr->rf_File)+3);
if(!PicArray[NumPictures])
{
printf("Out of memory!\n");
FreeAslRequest(fr);
CloseLibrary(AslBase);
CloseDisplay();
exit(10);
}
strcpy(PicArray[NumPictures], fr->rf_Dir);
i = strlen(fr->rf_Dir);
if(i)
{
i--;
if(fr->rf_Dir[i] != ':' && fr->rf_Dir[i] != '/')
strcat(PicArray[NumPictures], "/");
}
strcat(PicArray[NumPictures], fr->rf_File);
NumPictures++;
}
}
FreeAslRequest(fr);
}
CloseLibrary(AslBase);
AslBase = NULL;
}
}